
package red;


import consumidor.Buffer;
import consumidor.InterfaceUsuario;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Servidor {
    private ServerSocket servidor;
    private Socket socket;
    public int puerto = 8001;

    public Servidor(Buffer b) {
        try {
            servidor = new ServerSocket(puerto);
            System.out.println("Servidor iniciado, Esperando conexiones...");
            while(true){
                socket = servidor.accept();
                Thread conexion = new InterfaceUsuario(socket, b);
                conexion.start();
                System.out.println("Conexion aceptada");
            }
        } catch (IOException e) {
            System.err.println("Server constructor IOEx: " + e);
        }
    }
}